package com.lhkj.ct.meta.admin.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.lhkj.ct.base.enums.ActionType;
import com.lhkj.ct.base.enums.OperatorType;
import com.lhkj.ct.base.json.databind.BaseEnumDeserializer;
import com.lhkj.ct.base.json.databind.BaseEnumWritingByLabelSerializer;
import com.lhkj.ct.base.mybatis.IBaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.time.LocalDateTime;

@NoArgsConstructor
@AllArgsConstructor
@Data
@TableName(value = "tbl_operation_log")
@Builder(builderMethodName = "OperationLogBuilder", buildMethodName = "builder", builderClassName = "",
        toBuilder = true, access = AccessLevel.PUBLIC, setterPrefix = "")
public class TblOperationLog implements IBaseEntity<String> {

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private String id;

    @ApiModelProperty("接口描述")
    private String title;

    @ApiModelProperty(value = "操作类型")
    @JsonSerialize(using = BaseEnumWritingByLabelSerializer.class)
    @JsonDeserialize(using = BaseEnumDeserializer.class)
    private ActionType actionType;

    @ApiModelProperty("来源ip(操作ip)")
    private String clientIp;

    @ApiModelProperty("操作地点")
    private String operateLocation;

    @ApiModelProperty("客户端信息")
    private String userAgent;

    @ApiModelProperty(value = "请求地址", example = "/api/system/get")
    private String requestUri;

    @ApiModelProperty(value = "请求方式", notes = "POST, GET等等")
    private String httpMethod;

    @ApiModelProperty(value = "应用内方法名", notes = "类名+方法名")
    private String method;

    @ApiModelProperty("请求参数")
    private String requestParams;

    /** 操作状态（0正常 1异常） */
    @ApiModelProperty(value = "请求结果", notes = "0.正常 1.异常")
    private Integer status;

    @ApiModelProperty("请求结果")
    private String jsonResult;

    @ApiModelProperty("错误信息")
    private String errorMsg;

    @ApiModelProperty("操作人类别")
    @JsonSerialize(using = BaseEnumWritingByLabelSerializer.class)
    @JsonDeserialize(using = BaseEnumDeserializer.class)
    private OperatorType operatorType;

    @ApiModelProperty("操作人账号")
    private String operatorNo;

    @ApiModelProperty("操作人名称")
    private String operatorName;

    @ApiModelProperty(value = "消耗时间", notes = "毫秒")
    private Long costTime;

    @ApiModelProperty("创建时间")
    private LocalDateTime createTime;

}
